package com.rr.mymoney.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.rr.mymoney.model.enums.TransactionType;

@Entity
@Table(name = "budget_item")
@SequenceGenerator(name = "month_item_seq", sequenceName = "month_item_seq")
public class BudgetItem implements Serializable {

    private static final long serialVersionUID = -9038012236525241239L;

    private Long id;
    private Float value;
    private Currency currency;
    private TransactionType type;
    private Category category;
    private Date date;
    private String details;
    private MonthBudget monthBudget;

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(generator = "month_item_seq", strategy = GenerationType.AUTO)
    public Long getId() {
	return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Long id) {
	this.id = id;
    }

    /**
     * @return the value
     */
    @Column(name = "value", nullable = false)
    public Float getValue() {
	return value;
    }

    /**
     * @param value
     *            the value to set
     */
    public void setValue(Float value) {
	this.value = value;
    }

    /**
     * @return the currency
     */
    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "currency_id", nullable = false)
    public Currency getCurrency() {
	return currency;
    }

    /**
     * @param currency
     *            the currency to set
     */
    public void setCurrency(Currency currency) {
	this.currency = currency;
    }

    /**
     * @return the type
     */
    @Column(name = "type", nullable = false)
    public TransactionType getType() {
	return type;
    }

    /**
     * @param type
     *            the type to set
     */
    public void setType(TransactionType type) {
	this.type = type;
    }

    /**
     * @return the category
     */
    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "category_id")
    public Category getCategory() {
	return category;
    }

    /**
     * @param category
     *            the category to set
     */
    public void setCategory(Category category) {
	this.category = category;
    }

    /**
     * @return the monthBudget
     */
    @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "month_budget_id", nullable = false)
    public MonthBudget getMonthBudget() {
	return monthBudget;
    }

    /**
     * @param monthBudget
     *            the monthBudget to set
     */
    public void setMonthBudget(MonthBudget monthBudget) {
	this.monthBudget = monthBudget;
    }

    /**
     * @return the date
     */
    @Column(name = "date")
    public Date getDate() {
        return date;
    }

    /**
     * @param date the date to set
     */
    public void setDate(Date date) {
        this.date = date;
    }

    /**
     * @return the details
     */
    @Column(name = "details", length = 1000)
    public String getDetails() {
        return details;
    }

    /**
     * @param details the details to set
     */
    public void setDetails(String details) {
        this.details = details;
    }
}
